// Written by Steve Andersen, copyright (c) 2007 ONE/Northwest
// This program is released under the GNU General Public License. http://www.gnu.org/licenses/
public class Test_Project_Consulting_Fee_Change {
//create an opp
	//create a task log
	//check for values
	static testMethod void TestConsultingFeeCreated() {	 
		Id OppId;
		//create first contact
		Opportunity firstOpp = new Opportunity (Name='test opp',StageName='Prospecting',CloseDate=System.today());
		insert firstOpp;
		OppId = firstOpp.id;
		
		Project_Consulting_Fee__c firstConsultingFee = new Project_Consulting_Fee__c (
			Name='consulting fee 1',
			Opportunity__c=OppId,
			Amount__c=600
		);
		insert firstConsultingFee;
		Opportunity[] OppAfterConsultingFee = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(600,OppAfterConsultingFee[0].Fees_to_Consultants__c);
		
		firstConsultingFee.Amount__c=800;
		update firstConsultingFee;
		
		Opportunity[] OppAfterConsultingFeeChange = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(800,OppAfterConsultingFeeChange[0].Fees_to_Consultants__c);
		
		Project_Consulting_Fee__c secondConsultingFee = new Project_Consulting_Fee__c (
			Name='consulting fee 2',
			Opportunity__c=OppId,
			Amount__c=3500
		);
		insert secondConsultingFee;
		
		Opportunity[] OppAfterConsultingFeeAdd = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(4300,OppAfterConsultingFeeAdd[0].Fees_to_Consultants__c);
		
		Project_Consulting_Fee__c thirdNullConsultingFee = new Project_Consulting_Fee__c (
			Name='consulting fee 2',
			Opportunity__c=OppId,
			Amount__c=null
		);
		insert thirdNullConsultingFee;
		
		Opportunity[] OppAfterConsultingFeeNull = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(4300,OppAfterConsultingFeeNull[0].Fees_to_Consultants__c);
		
		//delete firstConsultingFeeLog;
		delete firstConsultingFee;
		
		Opportunity[] OppAfterConsultingFeeDelete = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(3500,OppAfterConsultingFeeDelete[0].Fees_to_Consultants__c);
		
		delete secondConsultingFee;
		
		Opportunity[] OppAfterConsultingFeeDelete2 = [select Fees_to_Consultants__c from Opportunity where Id =:OppId];
		System.assertEquals(0,OppAfterConsultingFeeDelete2[0].Fees_to_Consultants__c);
		
		
		
	}
}